class: center, middle, inverse, title-slide # Lecture 1 ## Syllabus, Review R ### Psych 10 C ### University of California, Irvine ### 03/28/2022 --- class: middle, center # Welcome to Psych 10 C --- ## Psych 10 C -- - This is the third course in the series. -- - Instructor: Manuel Villarreal <p style="color:purple;">jesusmv1@uci.edu</p> -- - TA's: - Adriana Chavez <p style="color:purple;">achavezd@uci.edu</p> - Arsenii Moskvichev <p style="color:purple;">amoskvic@uci.edu</p> - Jeff Coon <p style="color:purple;">jcoon1@uci.edu</p> - Jing Zhang <p style="color:purple;">jingz18@uci.edu</p> --- ## Structure of the course - Goal: to learn how and when to use linear models to answer questions about data. -- - Evaluation: - 5 homework assignments - 1 final project -- - Both require the use of R code, however, this is not a coding class so you will be able to find what you need on the slides. -- - We will provide homework templates that you will need to fill in (except for the final). --- ## Grading: - Each homework will be worth 10 points while the final project is worth 50, for a total of 100 points. -- - Grades will be assigned as follows: | Grade| Interval | Grade | Interval | Grade | Interval | |------|--------------|-------|--------------|-------|------------| | A+ | 100 to 96.5 | A | 96.4 to 93.5 | A- | 93.4 to 90 | | B+ | 89.9 to 86.5 | B | 86.4 to 83.5 | B- | 83.4 to 80 | | C+ | 79.9 to 76.5 | C | 76.4 to 73.5 | C- | 73.4 to 70 | | D+ | 69.9 to 66.5 | D | 66.4 to 63.5 | D- | 63.4 to 60 | | F | 59.9 to 0 | | | | | --- ## Discussion sections - Try to go only to the discussion section that you are registered for, otherwise there might not be enough space. -- - If you can't make it to your discussion section and would like to go to another, consult it with the TAs assigned to your section and the section that you plan to attend. -- - All discussion sections will take place in ALP 3600 --- ## How to Contact us - The best way to contact us is via email, we will try to respond within the following 24 hrs and only during weekdays. -- - Try to look at the homework and see if you have any questions. We can't promise that we will be able to respond in time if the deadline is close. -- - The syllabus is on Canvas, make sure to read it. --- class: inverse, middle, center # Review R --- ## RStudio and RStudio cloud - There are two ways in which you can get R and RStudio for this class. -- 1. Install [R](https://cran.microsoft.com/) and [Rstudio](https://www.rstudio.com/products/rstudio/download/#download) on your desktop/laptop. - First download and install R and then RStudio. 1. Start an account in [RStudio Cloud](https://rstudio.cloud/). -- - Both methods are free! -- - We have a small introduction to RStuido Cloud in Canvas. --- ## RStudio - RStudio is a graphical interface for R. - The window is divided in four parts. -- ## Set up - We will be working with Rmarkdown, an extension of R, which requires you to install the following package in order to generate the `.pdf` file that you have to submit for your homework. -- - Copy, paste, and then run the following two lines in your RStudio console ```r # install tinytex package install.packages('tinytex') #install tinytex to be able to generate pdf files tinytex::install_tinytex() ``` - You only need to do this once! --- ## Tidyverse - For this class we will use many functions that are not part of base R but that are in a separate package called `tidyverse`. -- - To download and install the [tidyverse](https://www.tidyverse.org/packages/) package you can copy and paste the following line of code into RStudio ```r # install tidyverse core packages install.packages("tidyverse") ``` - Again you only need to do this once! --- ## Tidyverse - Packages in R are code that other people have written and made available. This code takes the form of functions that we can use after downloading the package. -- - Many people use `tidyverse` so if you ever have a question and you can't reach us, you can Google it! -- - I promise someone else has asked that question and there will be a good answer. --- class: inverse, center, middle # Loading data into R --- ## Loading data - On days when each homework is scheduled to be released, we will provide a link to the corresponding data by the end of the lecture time -- - You can use that link to load the data file(s) into R. -- ## Let's start with an example - First we need to load the `tidyverse` package into R using -- - Then we can load the data using one of the functions included in the package `read_csv()` --- ## Loading data into RStudio ```r # Load the tydyverse library of functions library(tidyverse) # we are creating a variable called link to store the address # of the file as a character string with the url # of the file link <- "https://raw.githubusercontent.com/ManuelVU/psych-10c-data/main/example.csv" # the read_csv() function is part of the core packages in tidyverse, # we will load the file and save it with the name 'memory' memory <- read_csv(file = link) ``` - Note that the URL we give to R needs to be surrounded by quotation marks. --- ## Explore data file
--- ## Explore data file - We can look at the first rows of our data by doing the following: ```r # this will show us the first 6 rows of the file on # the console or in the scrip if we are using Rmarkdown # (as you will be for homework) head(x = memory, n = 6) ``` ``` ## # A tibble: 6 × 4 ## id age correct time_test ## <dbl> <dbl> <dbl> <dbl> ## 1 1 20 46 300 ## 2 2 29 49 300 ## 3 3 29 48 300 ## 4 4 25 44 300 ## 5 5 23 45 300 ## 6 6 26 44 300 ``` --- ## Homework data links: - link for homework problem 1: ```r # link for data problem 1 link_1 <- "https://raw.githubusercontent.com/ManuelVU/psych-10c-data/main/hw-problem-1.csv" ``` - link for homework problem 2: ```r # link for data problem 2 link_2 <- "https://raw.githubusercontent.com/ManuelVU/psych-10c-data/main/hw-problem-2.csv" ```